using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu(fileName = "PopupList", menuName = "ScriptableObject/UI_PopupList", order = 0)]
public class PopupList_Scriptable : ScriptableObject
{  
    public List< UI_Popup_Base> popups;
    public Dictionary<string, int> popup_Dictionary;
    public int Count
    {
        get
        {
            return popups.Count;
        }
    }
    public UI_Popup_Base this[string name]
    {
        get
        {
            if (Contains(name))
            {
                return popups[popup_Dictionary[name]];
            }
            return null;
        }
    }

    public bool Contains(string name)
    {
        if (popup_Dictionary == null)
        {
            popup_Dictionary = new Dictionary<string, int>();
            for (int i = 0; i < popups.Count; i++)
            {
                popup_Dictionary.Add(popups[i].popupName, i);
            }
        }
        return popup_Dictionary.ContainsKey(name);
    }

}
